<template>
  <div class="storeConfigure">
    <el-form :inline="true" :model="productForm" ref="productForm" class="form-inline">
      <el-form-item label="是否支持配送">
        <span>{{isDistribution}}</span>
      </el-form-item><br />
      <el-form-item label="金币锁定周期">
        <div class="grid-content bg-purple-light">
          <el-select v-model="productForm.toCoinDay" slot="prepend" placeholder="全部">
            <el-option label="0" value="0"></el-option>
            <el-option label="1" value="1"></el-option>
            <el-option label="2" value="2"></el-option>
            <el-option label="3" value="3"></el-option>
            <el-option label="4" value="4"></el-option>
            <el-option label="5" value="5"></el-option>
            <el-option label="6" value="6"></el-option>
            <el-option label="7" value="7"></el-option>
          </el-select>天
        </div>
      </el-form-item><br />
       <el-form-item label="售后退换周期">
        <div class="grid-content bg-purple-light">
          <el-select v-model="productForm.returnGoodsDay" slot="prepend" placeholder="全部">
            <el-option label="0" value="0"></el-option>
            <el-option label="1" value="1"></el-option>
            <el-option label="2" value="2"></el-option>
            <el-option label="3" value="3"></el-option>
            <el-option label="4" value="4"></el-option>
            <el-option label="5" value="5"></el-option>
            <el-option label="6" value="6"></el-option>
            <el-option label="7" value="7"></el-option>
          </el-select>天
        </div>
      </el-form-item><br />
      <el-form-item>
        <el-button type="primary" @click="configureSubmit">确认</el-button>
        <el-button @click="cancelBtn">取 消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  import axios from 'axios'
  export default{
    name: 'storeConfigure',
    data () {
      return {
        productForm: {
          returnGoodsDay: '',
          toCoinDay: '',
          storeSysno: this.$route.params.id
        },
        details: {},
        isDistribution: ''
      }
    },
    methods: {
      configureSubmit () {
        var params = this.productForm
        axios.post('/api/shop/editShop', params).then((res) => {
          if (res.data.code === 9999) {
            this.$message({
              type: 'success',
              message: '修改店铺配置成功'
            })
            this.$router.push('/storeInfo/' + this.$route.params.id)
          }
        })
      },
      cancelBtn () {
        this.$router.push('/storeInfo/' + this.$route.params.id)
      }
    },
    mounted () {
      axios.post('/api/shop/queryShopDetail', {storeSysno: this.$route.params.id}).then((res) => {
        if (res.data.code === 9999) {
          this.details = res.data.data
          if (this.details.isDistribution === 0) {
            this.isDistribution = '是'
          } else {
            this.isDistribution = '否'
          }
        }
      })
    }
  }
</script>
<style scoped lang='less'>
  .storeConfigure{
    text-align:center;
    margin-top:100px;
  }
</style>
